
TRIGGER PROCEDURE FOR DELETE OF WR_ROUTE.

{mfdeclre.i }
define new shared work-table wf_old_wr_route like wr_route.

HK:
do:
    if can-find(first dt_mstr where dt_table = "wr_route" and dt_type = "SYNC") then
        run CreateSyncFlag(input "DEL", input recid(wr_route), input "wr_route").

    if not can-find ( first dt_mstr where dt_table = "wr_route" and dt_type = "DEL" ) then leave HK.
    
    if not can-find ( first wf_old_wr_route ) then do:
        create wf_old_wr_route.
        if recid(wf_old_wr_route)= -1 then .
    end.
    
    buffer-copy wr_route to wf_old_wr_route no-error.

    for first dt_mstr no-lock where dt_table = "wr_route" and dt_type = "DEL" :
    
    	run CreateDthist(input dt_table, input dt_field, input dt_type, input "", input "", 
        	input recid(wr_route), input wr_route.wr_nbr, input string(wr_route.wr_op), input wr_route.wr_lot, input "",
        	input "", input "", input "", input "") .
        	
    end.
end.

{hkdttrans.i}
